package com.xuetang9.t9.hotel.controller;

import com.xuetang9.t9.hotel.beans.RolePermission;
import com.xuetang9.t9.hotel.services.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName PositionController
 * @Description TODO
 * @Author qin
 * @Date 2020/3/2 20:25
 * @Version 1.0
 **/
@Controller
@RequestMapping("posit")
public class PositionController {
    @Autowired
    private IPositionService positionService;

    @PostMapping("list")
    @ResponseBody
    private List<RolePermission> list(){
        return positionService.queryRoleList();
    }

    @PostMapping("insert")
    @ResponseBody
    private List<RolePermission> insert(@RequestBody RolePermission rolePermission){
        positionService.insertRole(rolePermission);
        return positionService.queryRoleList();
    }

    @PostMapping("update")
    @ResponseBody
    private List<RolePermission> update(@RequestBody RolePermission rolePermission){
         positionService.updateRole(rolePermission);
         return positionService.queryRoleList();
    }

    @PostMapping("delete")
    @ResponseBody
    private List<RolePermission> delete(@RequestParam("id") Integer id){
        positionService.deleteRole(id);
        return positionService.queryRoleList();
    }

    @PostMapping("one")
    @ResponseBody
    private RolePermission selectOne(@RequestParam("id") Integer id){
        return positionService.queryOne(id);
    }

    @PostMapping("tank")
    @ResponseBody
    private List<RolePermission> tankList(){
        return positionService.queryTankList();
    }

}
